home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
src.arc
/
8530.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-02-21
|
2KB
|
131 lines
.MODEL MEMMOD,C
LOCALS
%MACS
.LALL
.CODE
; Write a 8530 register. Called from C as
; write_scc(int ctl,char reg,char val);
public write_scc
write_scc proc
arg ctl:word,reg:byte,val:byte
pushf
mov dx,ctl
mov al,reg
cmp al,0
jz @@doit ; no need to set register 0
cli
out dx,al
; allow enough delay for 10 MHz 80286 and a 3.6 MHz 8530
; each nop is 3 clock ticks (300 ns @ 10 MHz).
; The 8530 requires a delay of 6 PCLK cycles (1.666 uS at 3.6 MHz)
nop
nop
nop
nop
nop
nop
@@doit: mov al,val
out dx,al
popf
ret
write_scc endp
; Read a 8530 register. Called from C as
; read_scc(int ctl,char reg);
public read_scc
read_scc proc
arg ctl:word,reg:byte
pushf
mov dx,ctl
mov al,reg
cmp al,0
jz @@doit ; no need to set reg if R0
cli
out dx,al
; allow enough delay for 10 MHz 80286 and a 3.6 MHz 8530
nop
nop
nop
nop
nop
nop
@@doit: in al,dx
mov ah,0
popf
ret
read_scc endp
; Read packets from the 8530 receiver.
; Returns when either a good frame is received, or when carrier drops.
; If a good frame is received, the length is returned; otherwise -1.
public rx8530
rx8530 proc
arg ctl:word,data:word,buf:ptr,bufsize:word
uses di
@@restart:
if @Datasize NE 0
les di,buf
else
mov di,buf ; cp = buf
mov ax,ds
mov es,ax
endif
cld
mov cx,0 ; cnt = 0
@@rxloop:
mov dx,ctl ; read status
in al,dx ; into al
test al,08h ; DCD still present?
jz @@dcdoff ; nope, quit
test al,080h ; Abort?
jnz @@restart ; yes, start again
test al,01h ; character available?
jz @@nochar ; nope, go on
mov dx,data
in al,dx ; get it
stosb ; and stash: *cp++ = char
inc cx ; cnt++
cmp cx,bufsize ; cx == bufsize?
jnz @@rxloop
mov dx,ctl ; buffer overflowed; abort receiver
mov al,3 ; select register 3
out dx,al
mov al,0d9h ; ENT_HM|RxENABLE|RxCRC_ENAB|Rx8
nop
nop
nop
nop
nop
out dx,al
jmp @@restart
@@nochar:
mov al,1 ; Select error register (R1)
mov dx,ctl
out dx,al
nop
nop
nop
nop
nop
nop
in al,dx ; read error reg (R1)
test al,080h ; end of frame?
jz @@rxloop ; nope, keep looking
test al,040h ; End of frame. CRC error?
jnz @@restart ; yup; start again
mov ax,cx ; good frame; return with count
ret
@@dcdoff:
mov ax,0ffffh ; DCD dropped, return -1
ret
rx8530 endp
end